package example.androiddemo.ui.Act;

import android.content.Intent;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;

import butterknife.BindView;
import butterknife.ButterKnife;
import example.androiddemo.R;

public class SplashActivity extends BaseActivity {
    @BindView(R.id.iv_splash)
    ImageView ivSplash;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        ButterKnife.bind(this);
        startAnimation();
    }

    private void startAnimation() {
        ScaleAnimation scaleAnimation = new ScaleAnimation(
                1, 1.1f, 1, 1.1f,
                Animation.RELATIVE_TO_SELF, 0.5f,
                Animation.RELATIVE_TO_SELF, 0.5f
        );
        scaleAnimation.setDuration(2000);
        scaleAnimation.setFillAfter(true);

        scaleAnimation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationStart(Animation animation) {

            }

            @Override
            public void onAnimationEnd(Animation animation) {
                // TODO: 2016/9/20 检查权限  检查版本更新

//                checkVersion();
                startActivity(new Intent(SplashActivity.this,MainActivity.class));


             /*   RxPermissions.getInstance(SplashActivity.this).request(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                        .subscribe(new Action1<Boolean>() {
                            @Override
                            public void call(Boolean aBoolean) {
                                if (aBoolean) {

                                } else {

                                }
                            }
                        });*/
            }

            @Override
            public void onAnimationRepeat(Animation animation) {

            }
        });

        ivSplash.startAnimation(scaleAnimation);
    }

    private void checkVersion() {


    }


}
